package com.shape;

public class Circle implements Shape {
    private double radius;

    public Circle(double radius) {
        if (radius <= 0) {
            throw new IllegalArgumentException("半径必须大于0");
        }
        this.radius = radius;
    }

    @Override
    public double getArea() {
        return Math.PI * radius * radius;
    }

    @Override
    public double getPerimeter() {
        return 2 * Math.PI * radius;
    }

    @Override
    public String getName() {
        return "圆形";
    }

    public double getRadius() {
        return radius;
    }

    @Override
    public String toString() {
        return String.format("圆形(半径=%.2f) - 面积: %.2f, 周长: %.2f",
                radius, getArea(), getPerimeter());
    }
}